package servlet;

import javax.servlet.*;
import java.io.IOException;

//第一种实现方式
public class FirstServlet implements Servlet {
    //静态块 类被加载的时候执行
    static {
        System.out.println("first...");
    }
    //无参构造器 当类被new的时候执行
    public FirstServlet(){
        System.out.println("firstServlet");
    }
    private ServletConfig config;
    @Override//初始化
    public void init(ServletConfig servletConfig) throws ServletException {
        config = servletConfig;
        System.out.println("我是FirstServlet中的init方法");
    }

    @Override
    public ServletConfig getServletConfig() {
        return config;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("我是FirstServlet中的service方法");
    }

    @Override
    public String getServletInfo() {
        return "你好中国";
    }

    @Override
    public void destroy() {
        System.out.println("我是FirstServlet中的destroy方法");
    }
}
